//
//  MoreViewController.m
//  Project_2_weibo
//
//  Created by 林林 on 16/6/16.
//  Copyright © 2016年 lhn. All rights reserved.
//

#import "MoreViewController.h"


@interface MoreViewController ()
@property (weak, nonatomic) IBOutlet ThemeImageView *icon1;
@property (weak, nonatomic) IBOutlet ThemeImageView *icon2;
@property (weak, nonatomic) IBOutlet ThemeImageView *icon3;
@property (weak, nonatomic) IBOutlet ThemeImageView *icon4;

@property (weak, nonatomic) IBOutlet ThemeLabel *label1;
@property (weak, nonatomic) IBOutlet ThemeLabel *label2;
@property (weak, nonatomic) IBOutlet ThemeLabel *label3;
@property (weak, nonatomic) IBOutlet ThemeLabel *label4;
@property (weak, nonatomic) IBOutlet ThemeLabel *label5;
@property (weak, nonatomic) IBOutlet ThemeLabel *label6;

@end

@implementation MoreViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"更多";
    //设置背景图片
    ThemeImageView *bgImageView = [[ThemeImageView alloc] initWithFrame:self.view.bounds];
    bgImageView.imageName = @"bg_home.jpg";
    [self.view insertSubview:bgImageView atIndex:0];
    
    //设置图标
    _icon1.imageName = @"more_icon_theme.png";
    _icon2.imageName = @"more_icon_account.png";
    _icon3.imageName = @"more_icon_draft.png";
    _icon4.imageName = @"more_icon_feedback.png";
    
    //设置字体
    _label1.colorName = @"More_Item_Text_color";
    _label2.colorName = @"More_Item_Text_color";
    _label3.colorName = @"More_Item_Text_color";
    _label4.colorName = @"More_Item_Text_color";
    _label5.colorName = @"More_Item_Text_color";
    _label6.colorName = @"More_Item_Text_color";
    
    //设置按钮
    [self createBarButton];
}

- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    _label2.text = [ThemeManager sharedManager].themeName;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.row == 0 && indexPath.section == 0) {
        
        UIViewController *theme = [self.storyboard instantiateViewControllerWithIdentifier:@"ThemeSelectController"];
        //push时隐藏标签栏
        theme.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:theme animated:YES];
    }
    
}

- (void)createBarButton {
    //创建设置按钮
    ThemeButton *setButton = [ThemeButton buttonWithType:UIButtonTypeCustom];
    setButton.frame = CGRectMake(0, 0, 60, 44);
    [setButton setTitle:@"设置" forState:UIControlStateNormal];
    [setButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    setButton.backgroundImageName = @"titlebar_button_9";
    //添加点击事件
    [setButton addTarget:self action:@selector(barButtonAction) forControlEvents:UIControlEventTouchUpInside];
    //包装为BarButton
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:setButton];
    self.navigationItem.leftBarButtonItem = item;
}

- (void)barButtonAction {
    
    //用MMDrawer提供的类目获取MMDrawer控制器
    MMDrawerController *mmdVC = self.mm_drawerController;
    //点击打开
    [mmdVC openDrawerSide:MMDrawerSideLeft animated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
